﻿
using System.Windows;
using System.Windows.Media;

namespace Cyl.ImageControl;

public class LineROI : ROI
{
    public Point StartPoint { get; set; }
    public Point EndPoint { get; set; }

    public override void Draw(DrawingContext dc, double scale, Point offset)
    {
        ApplyTransform(dc, scale, offset);
        dc.DrawLine(new Pen(new SolidColorBrush(Color), 2), StartPoint, EndPoint);
        dc.Pop();
    }

    public override Point[] GetControlPoints()
    {
        return new Point[]
        {
                StartPoint,
                EndPoint
        };
    }

    public override void UpdateControlPoint(Point controlPoint, Point newPosition)
    {
        if (controlPoint == StartPoint)
        {
            StartPoint = newPosition;
        }
        else if (controlPoint == EndPoint)
        {
            EndPoint = newPosition;
        }
    }

    public override void Move(Point offset)
    {
        StartPoint = new Point(StartPoint.X + offset.X, StartPoint.Y + offset.Y);
        EndPoint = new Point(EndPoint.X + offset.X, EndPoint.Y + offset.Y);
    }
}
